const env = process.env;
const NODE_ENV = env.NODE_ENV;

let environment = {
    LOG_PATH: "./logs",
    HTTP: {
        GET: "http://127.0.0.1:8080",
        POST: "127.0.0.1",
        PORT: 8080
    },
    DB: {
        database: "dang",
        username: "root",
        password: "root",
        options: {
            dialect: "mysql",
            operatorsAliases: false,
            benchmark: true,
            pool: {
                max: 10,
                min: 1,
                acquire: 30000,
                idle: 10000
            }
        }
    },
    isDev() {
        return NODE_ENV === 'development';
    }
}

if (!environment.isDev()) {
    let env_data = {
        LOG_PATH: env.LOG_PATH,
        HTTP: JSON.parse(env.HTTP),
        DB: JSON.parse(env.DB)
    }
    Object.assign(environment, env_data);
    console.log("配置文件数据:" + JSON.stringify(environment));
}

module.exports = environment;